package com.obixlabs.smorgasbord.domainmodel.security;

import java.util.Arrays;

public class UserImpl implements User
{	
	private static final long serialVersionUID = -7638431186527129623L;

	private String givenName;
	private Integer id;
	private String emailAddress;
	private String handle;
	
	@Override
	public String getName() { return this.getEmailAddress();}
	
	@Override
	public Integer getId() { return this.id; }
	
	public void setId(Integer id) { this.id = id; }

	@Override
	public String getEmailAddress() { return this.emailAddress; }

	public void setEmailAddress(String emailAddress)
	{ this.emailAddress = emailAddress; }
	
	@Override
	public String getHandle() { return this.handle; }

	public void setHandle(String handle) { this.handle = handle; }
	
	@Override
	public String getGivenName() { return this.givenName; }
	
	public void setGivenName(String fullName)
	{ this.givenName = fullName;}

	@Override
	public boolean equals(Object obj)
	{
		boolean result;
		
		if (this == obj)
			result = true;
		else if (obj instanceof UserImpl)
		{
			UserImpl other = (UserImpl) obj;
			Object[] fields = {this.id, this.givenName, this.handle, this.emailAddress};
			Object[] otherFields = {other.id, other.givenName, other.handle, other.emailAddress};
			result = Arrays.equals(fields, otherFields);
		}
		else result = false;		
		
		return result;
	}
}